<template>
    <div>
       <el-card class="box-card">
  <div slot="header" class="clearfix">
  <el-row :gutter="20">
  <el-col :span="12"><div class="grid-content bg-purple">   <el-input placeholder="请输入内容"  class="input-with-select" v-model="goods.query" >
   
    <el-button slot="append" icon="el-icon-search" @click="goodget"></el-button>
  </el-input></div></el-col>
  <el-col :span="6"><div class="grid-content bg-purple">  <el-button type="primary" @click="f1">添加</el-button></div></el-col>
 
</el-row>
  </div>

   <el-table
      :data="tableData"
      style="width: 100%">
      <el-table-column
        type='index'
        label="#"
       >
      </el-table-column>
      <el-table-column
        prop="goods_name"
        label="商品名称"
          width="480"
        >
      </el-table-column>
      <el-table-column
        prop="goods_price"
        label="商品价格">
      </el-table-column>
      <el-table-column
        prop="goods_weight"
        label="商品重量">
      </el-table-column>
      <el-table-column
        prop="add_time"
        label="创建时间">
      </el-table-column>
      <el-table-column
        prop="address"
        label="操作">
        <template v-slot="scope">
        
                
             <button @click="sc(scope.row.goods_id)"> 删除</button>
        </template>
       
      </el-table-column>
    </el-table>
</el-card>


    </div>
</template>
<script>
export default {
    data() {
        return {
            tableData:[],
            goods:{
                query:'',
                pagenum:1,
                pagesize:100
            }
        }
    },
    created() {
            this.goodget()
    },
    methods: {
          f1(){
            this.$router.push('/add')
          },
        async sc(ev){
              
                   await this.axios.delete(`/goods/${ev}`)
                   this.goodget()
        },
       async goodget(){
                        let {data:res} = await this.axios.get('/goods', {params:this.goods})
                       
                        this.tableData=res.data.goods
                        
        }
    },
}
</script>
<style lang="scss" scoped>

</style>